/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import pojo.Cauhoi;
import util.HibernateUtil;

/**
 *
 * @author kydrenw
 */
public class CauhoiDAO {
     //
    // Lấy thông tin
    //
    public static Cauhoi layThongTin(int ma) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        Cauhoi sp = (Cauhoi) session.get(Cauhoi.class, ma);
        
        return sp;
    }
    //
    // Lấy danh sách
    //
    public static List<Cauhoi> layDanhSach() {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        String hql = "FROM Cauhoi";
        Query query = session.createQuery(hql);
        List<Cauhoi> ds = query.list();
        
        return ds;
    }
}
